using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using Terra.Core.Common.ApiResponse;
using Terra.Core.Common.Models.Pagination;
using Terra.Data.Models.Loggings;

namespace Terra.Service.Logging.Interfaces;

/// <summary>
/// 异常日志服务接口
/// </summary>
public interface IExceptionLogService
{
    /// <summary>
    /// 分页查询异常日志
    /// </summary>
    /// <param name="query">查询参数</param>
    /// <returns>分页结果</returns>
    Task<ApiResponse<PagedList<ExceptionItemDto>>> GetPagedListAsync(ExceptionQueryDto query);

    /// <summary>
    /// 获取异常日志详情
    /// </summary>
    /// <param name="id">异常日志ID</param>
    /// <returns>异常日志详情</returns>
    Task<ApiResponse<ExceptionDetailDto>> GetByIdAsync(Guid id);

    /// <summary>
    /// 获取异常统计信息
    /// </summary>
    /// <param name="startTime">开始时间</param>
    /// <param name="endTime">结束时间</param>
    /// <returns>异常统计信息</returns>
    Task<ApiResponse<List<ExceptionStatsDto>>> GetExceptionStatsAsync(DateTime? startTime, DateTime? endTime);

    /// <summary>
    /// 获取异常统计数据（前端格式）
    /// </summary>
    /// <param name="startTime">开始时间</param>
    /// <param name="endTime">结束时间</param>
    /// <returns>异常统计结果（前端格式）</returns>
    Task<ApiResponse<List<ExceptionStatsFrontendDto>>> GetFrontendStatsAsync(DateTime? startTime, DateTime? endTime);

    /// <summary>
    /// 清理指定时间之前的异常日志
    /// </summary>
    /// <param name="beforeTime">清理该时间之前的日志</param>
    /// <returns>清理的记录数</returns>
    Task<ApiResponse<int>> CleanAsync(DateTime beforeTime);

    /// <summary>
    /// 批量删除异常日志
    /// </summary>
    /// <param name="ids">日志ID列表</param>
    /// <returns>删除的记录数</returns>
    Task<ApiResponse<int>> BatchDeleteAsync(IEnumerable<Guid> ids);

    /// <summary>
    /// 导出异常日志
    /// </summary>
    /// <param name="query">查询参数</param>
    /// <returns>导出的文件内容</returns>
    Task<ApiResponse<byte[]>> ExportAsync(ExceptionQueryDto query);
}